import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { LeadVO, LeadForm, LeadQuery } from '@/api/hrp/lead/types';

/**
 * 查询线索商机列表
 * @param query
 * @returns {*}
 */

export const listLead = (query?: LeadQuery): AxiosPromise<LeadVO[]> => {
  return request({
    url: '/hrp/lead/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询线索商机详细
 * @param id
 */
export const getLead = (id: string | number): AxiosPromise<LeadVO> => {
  return request({
    url: '/hrp/lead/' + id,
    method: 'get'
  });
};

/**
 * 新增线索商机
 * @param data
 */
export const addLead = (data: LeadForm) => {
  return request({
    url: '/hrp/lead',
    method: 'post',
    data: data
  });
};

/**
 * 修改线索商机
 * @param data
 */
export const updateLead = (data: LeadForm) => {
  return request({
    url: '/hrp/lead',
    method: 'put',
    data: data
  });
};

/**
 * 删除线索商机
 * @param id
 */
export const delLead = (id: string | number | Array<string | number>) => {
  return request({
    url: '/hrp/lead/' + id,
    method: 'delete'
  });
};
